package com.redis.jedistest;

import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;

/**
 * Created with IntelliJ IDEA.
 * Description:
 *
 * @author lzy
 * @date 2020-10-13 下午2:50
 */
public class JedisTest {
    public static void main(String[] args) {
        JedisPool pool = new JedisPool();
        try (final Jedis jedis = pool.getResource()) {
            doSomething(jedis);
        }

        RedisPool redis = new RedisPool();
        Holder<Long> countHolder = new Holder<>();
        redis.execute(jedis -> {
            long count = jedis.zcard("codehold");
            countHolder.value(count);
        });
        System.out.println(countHolder.value());
    }

    private static void doSomething(Jedis jedis) {
        // code it here
    }
}
